﻿import QtQuick 2.0
import QtQuick.Particles 2.0

//import "./common/"

Item {
    id: root
    width: gWidth
    height: gHeight

    property real gWidth: img.width
    property real gHeight: img.height

    property int num: 2

    property real gx: 0
    property real gy: 0

    property real maxx: 10
    property real maxy: 5

    property real screenx: 0
    property real screeny: 0

    Connections{
        target: widget
        //        onNotifyMousePos: {
        //            if(gx !== mx || gy !== my){
        //                gx = mx
        //                gy = my
        //                console.log("qml mouse: ", mx, my)
        //            }
        //        }
        onNotifyMouseScreenPos: {
            if(gx !== x || gy !== y){
                gx = x
                gy = y
                //console.log("qml mouse: ", x, y)

//                imgEye.x = (gx-0.5) * maxx
//                imgEye.y = (gy-0.5) * maxy
            }
        }
    }

    Image {
        id: img
        source: "qrc:/image/image/bg.png"
        sourceSize: Qt.size(img.width, img.height)
        smooth: true
        z: 1
    }

    MyPathAnim{
        id: myPathAnim1
        dir: 1
        dx: 31
        dy: 10
        displayCanvas: false
    }

    ParticleSystem { id: sys1 }
    ImageParticle {
        system: sys1
        source: "qrc:/image/image/glowdot.png"
        color: "cyan"
        alpha: 0
        SequentialAnimation on color {
            loops: Animation.Infinite
            ColorAnimation {
                from: "cyan"
                to: "magenta"
                duration: 1000
            }
            ColorAnimation {
                from: "magenta"
                to: "blue"
                duration: 2000
            }
            ColorAnimation {
                from: "blue"
                to: "violet"
                duration: 2000
            }
            ColorAnimation {
                from: "violet"
                to: "cyan"
                duration: 2000
            }
        }
        colorVariation: 0.3
    }

    Emitter {
        id: trailsNormal4  //鼠标效果
        system: sys1
        enabled: false
        x: myPathAnim1.targetX
        y: myPathAnim1.targetY

        emitRate: 500
        lifeSpan: 2000


        velocity: PointDirection { xVariation: 6; yVariation: 6; }
        acceleration: PointDirection {xVariation: 4; yVariation: 4;}
        velocityFromMovement: 0

        size: 16
        sizeVariation: 4
    }

}
